package cn.online.qa.service;


import cn.online.qa.entity.Answers;
import cn.online.qa.repository.AnswersServiceRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(readOnly = false)
public class AnswersService {
    @Autowired
    AnswersServiceRepository answersServiceRepository;

    //获得该问题的所有答案
    public List<Answers> getAnswers(long pid){
      return   answersServiceRepository.findAllByQid(pid);
    }

    public int addAnswer(Answers answers){
      answersServiceRepository.save(answers);
        return 1;
    }
}
